-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Avoid useless initializations of fci/fcc in array functions #18273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These cause cache misses due to global access, in phpstan (notably the array_map). Initializing these isn't necessary because ZPP initializes it for us. Only for optional arguments do we need to be careful; for `array_filter` we still reset the `fci` but not `fci_cache` because `fci` is not necessarily set by ZPP but is conditionally used to access `fci_cache`.
See php#18273, a constant may cause unnecessary cache misses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I never actually approved this. I checked all the cases again and this looks correct to me.
I guess its related to this PR, therefore posting it here. running phpstan/phpstan-src@b3d3386 on macOS considerable got faster: running 8376904 with
3 runs runtime:
vs. running 1684c52a88d with the same command: 3 runs runtime:
vs. PHP 8.3.20 (cli) (built: Apr 8 2025 20:21:18) (NTS) 3 runs runtime:
vs. PHP 8.4.5 (cli) (built: Mar 12 2025 01:55:56) (NTS) 3 runs runtime:
|
At least also because of the CALL VM optimization. |
Thanks to anyone involved 😎 //cc @arnaud-lb |
These cause cache misses due to global access, in phpstan (notably the array_map).
Initializing these isn't necessary because ZPP initializes it for us. Only for optional arguments do we need to be careful; for
array_filter
we still reset thefci
but notfci_cache
becausefci
is not necessarily set by ZPP but is conditionally used to accessfci_cache
.